using UnityEngine;

public class SaveLoadManager : MonoBehaviour
{
    private const string SAVE_KEY = "PlayerSaveData";

    public void SavePlayerData(PlayerData data)
    {
        string jsonData = JsonUtility.ToJson(data);
        PlayerPrefs.SetString(SAVE_KEY, jsonData);
        PlayerPrefs.Save();
    }

    public PlayerData LoadPlayerData()
    {
        if (PlayerPrefs.HasKey(SAVE_KEY))
        {
            string jsonData = PlayerPrefs.GetString(SAVE_KEY);
            return JsonUtility.FromJson<PlayerData>(jsonData);
        }
        return null;
    }

    public void DeleteSaveData()
    {
        PlayerPrefs.DeleteKey(SAVE_KEY);
    }
}